
#if defined(WIN32) || defined(WIN64)
#pragma unmanaged
#endif

#include <Liberty3D/Engine/Component.h>
#include <vector>

using namespace Liberty::Engine;

static std::vector<IComponentFactory*> factories;

void ComponentFactory::registerFactory(IComponentFactory* factory) {
    factories.push_back(factory);
}

std::shared_ptr<Component> ComponentFactory::create(const char* name) {
    std::vector<IComponentFactory*>::const_iterator it, end(factories.end());
    std::shared_ptr<Component>                      c;

    for (it = factories.begin(); it != end; ++it) {
        c = (*it)->create(name);

        if (c) {
            break;
        }
    }

    return c;
}
